package Week4.J0507;

import java.util.Scanner;

//jdffdjrgvd

public class 非对称之美_xv {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] arr = scanner.next().toCharArray();
        int len = arr.length;
        boolean flag = false;

        for (int i = 1; i < len; i++) {
            if (arr[i] != arr[0]) {
                flag = true;
                break;
            }
        }

        if (flag) {
            flag = false;
            int left = 0; int right = len - 1;
            while (left < right) {
                if (arr[left] == arr[right]) {
                    left++;
                    right--;
                }else {
                    flag = true;
                    break;
                }
            }
            if (flag) {
                System.out.println(len);
            }else {
                System.out.println(len - 1);
            }

        }else System.out.println(0);
    }
}
